﻿using Server.Constant;
using Server.Framework.Message;
using Server.Framework.Processor;
using Server.Framework.Socket;
using Server.Message.Request;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Server.Processor
{
    /// <summary>
    /// Author: Leil
    /// Description: FileSendProcessor
    /// CreateTime: 2020/6/16 15:41:37
    /// </summary>
    [ProcessorAttr(MessageId.SEND_FILE)]
    public class FileSendProcessor : IProcessor
    {
        public void Process(ProtobufAppSession session, RequestBaseMessage message)
        {
            if (message is FileSendReq msg)
            {
                File file = msg.file;
                byte[] bytes = file.Data.ToByteArray();
                using (FileStream fs = new FileStream(@"C:\Users\leil1\Desktop\test.txt", FileMode.Append))
                {
                    fs.Write(bytes, 0, file.Size);
                }
            }
        }
    }
}
